//
// Created by 谢哲 on 2021/4/22.
//

#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

vector<int> vdata;


void quick_sort(int l, int r) {
    if (r-l<=1) return;

    int i=l, j=r-1;
    int key = vdata[l];
    bool flag = true;

    while(i<j) {
        if (flag) {
            if (vdata[j] < key) {
                vdata[i] = vdata[j];
                ++i;
                flag = false;
            }
            else --j;
        }
        else {
            if (vdata[i] > key) {
                vdata[j] = vdata[i];
                --j;
                flag = true;
            }
            else ++i;
        }
    }

    vdata[i] = key;
    quick_sort(l, i);
    quick_sort(i+1, r);
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;

    vdata.resize(n);

    for (int i=0; i<n; ++i) {
        cin >> vdata[i];
    }

    srand(114514);

    for (int i=0; i<n; ++i) {
        int j = rand() % n;
        swap(vdata[i], vdata[j]);
    }

    quick_sort(0, n);

    for (auto p: vdata) cout << p <<" ";

    return 0;
}